﻿
IF EXISTS (SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' AND ROUTINE_NAME = 'parametrosBodegaGet')
	BEGIN
		DROP  Procedure  parametrosBodegaGet
	END
GO



CREATE PROCEDURE [dbo].[parametrosBodegaGet] 	
	(	
		@empresa_id AS INT,
		@sucursal_id AS INT		
	)	
AS
BEGIN	
	SET NOCOUNT ON
	
	SELECT 0 AS TableId, 'Catalog'			AS TableName	UNION
	SELECT 1 AS TableId, 'ParametrosBodega'			AS TableName	UNION
	SELECT 2 AS TableId, 'Bodega'		AS TableName
	  
	SELECT	EmpresaId, 
			SucursalId,	
			BodegaMateriaPrima, 
			BodegaProductoEnProceso, 
			BodegaProductoTerminado
	FROM Lit_ParametrosBodega
	WHERE EmpresaId = @empresa_id
	  AND SucursalId = @sucursal_id
	  
	SELECT	CONVERT(INT, Emp_Id) As EmpresaId,
			CONVERT(INT, Suc_Id) As SucursalId,
			CONVERT(INT, Bod_Id) As BodegaId,
			Bod_Nombre As BodegaNombre
	FROM Bodega
	WHERE Emp_Id = @empresa_id
	AND Suc_Id = @sucursal_id
	  
	SET NOCOUNT OFF
END
GO

  